//
//  HealthReportViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/22.
//

#import "HealthIndexViewController.h"
@interface ReportTableCell : UITableViewCell


@end

@implementation ReportTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self == [super initWithStyle: style reuseIdentifier:reuseIdentifier]){
        

        
        MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        root.myHorzMargin = 15;
        root.subviewHSpace = 10;
        [self.contentView addSubview:root];
        
        MyLinearLayout *left = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        left.mySize = CGSizeMake(14, 70);
        left.gravity = MyGravity_Horz_Center;
        [root addSubview:left];
        
        {
            UIImageView *statusImage = [[UIImageView alloc]initWithImage:UIImageMake(@"profile_report_old")];
            statusImage.mySize = CGSizeMake(14, 14);
            [left addSubview:statusImage];
            
            UIView *line = UIView.new;
            line.myWidth = 0.5;
            line.weight = 1;
            line.backgroundColor = HexColor(@"#E3E3E3");
            [left addSubview:line];
            
        }
        
        MyLinearLayout *middle = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        middle.weight = 1;
        middle.myHeight = 70;
        middle.subviewVSpace = 10;
        [root addSubview:middle];
        
        {
            UILabel *time = [UILabel createLabelText:@"2022-11-12" font:UIFontBoldMake(15) textColor:COLOR1515];
            time.mySize = kAutoSize;
            [middle addSubview:time];
            
            MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
            bottom.subviewHSpace = 20;
            bottom.myHeight = 20;
            bottom.myWidth = kAutoWidth;
            [middle addSubview:bottom];
            
            {
                UILabel *name = [UILabel new];
                name.mySize = kAutoSize;
                name.attributedText = AttributedString(@"检测者：", UIFontMake(13), COLOR999, @"孙志亮", UIFontBoldMake(14), COLOR1515, NSTextAlignmentLeft, 2);
                [bottom addSubview:name];
                
                UILabel *zhishu = [UILabel new];
                zhishu.mySize = kAutoSize;
                zhishu.attributedText = AttributedString(@"健康指数：", UIFontMake(13), COLOR999, @"73.0", UIFontBoldMake(14), COLOR1515, NSTextAlignmentLeft, 2);
                [bottom addSubview:zhishu];
            }
            
        }
        
        UIButton *chakan = [UIButton createButtonText:@"查看" font:UIFontMake(14) textColor:THEME_COLOR];
        ViewCorner(chakan, 13);
        ViewBorder(chakan, 0.5, THEME_COLOR);
        chakan.useFrame = YES;
        [chakan addTarget:self action:@selector(chakanClick) forControlEvents:UIControlEventTouchUpInside];
        [root addSubview:chakan];
        [chakan mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).offset(-15);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(50, 26));
        }];
        
    }
    return self;
}

- (void)chakanClick {
    HealthIndexViewController *vc = HealthIndexViewController.new;
    [[ZJCommon getTopController] showViewController:vc sender:self];
}

@end


#import "HealthReportViewController.h"

@interface HealthReportViewController ()<JXCategoryViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) JXCategoryTitleView      *categoryView;

@property(nonatomic,strong) UITableView *tableView;
@end

@implementation HealthReportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BACKGROUNDCOLOR;
    self.title = @"个人健康报告";
    
    
    
}

- (void)initSubviews {
    [super initSubviews];
    
    self.categoryView = [[JXCategoryTitleView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, kScreenWidth, 44)];
    self.categoryView.delegate = self;
    self.categoryView.titles = @[@"自我检测",@"大众检测"];
    self.categoryView.titleFont = UIFontMake(14);
    self.categoryView.titleSelectedFont = UIFontMake(14);
    self.categoryView.titleColor = COLOR666;
    self.categoryView.titleSelectedColor = THEME_COLOR;
    self.categoryView.titleColorGradientEnabled = YES;
    self.categoryView.defaultSelectedIndex = 0;
    [self.view addSubview:self.categoryView];
  
    JXCategoryIndicatorLineView *line = [[JXCategoryIndicatorLineView alloc] init];
    line.indicatorWidth = 30;
    line.indicatorColor = THEME_COLOR;
    line.lineStyle = JXCategoryIndicatorLineStyle_LengthenOffset;
    self.categoryView.indicators = @[line];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(15, self.categoryView.bottom + 15, kScreenWidth - 30, kScreenHeight - (self.categoryView.bottom + 15)- NavigationContentTop)];
    if (@available(iOS 11.0,*)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    self.tableView.dataSource = self;
    self.tableView.layer.cornerRadius = 15;
    self.tableView.backgroundColor = UIColorWhite;
    [self.tableView registerClass:[ReportTableCell class] forCellReuseIdentifier:@"ReportTableCell"];
    self.tableView.rowHeight = 70;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = false;
    [self.view addSubview:self.tableView];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        sleep(2);
        [self.tableView.mj_header endRefreshing];
    }];
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        NSLog(@"aaaaaaaaaaaa");
//        [self.tableView.mj_footer endRefreshing];
    }];
    
    
    MyLinearLayout *headerView = [[MyLinearLayout alloc]initWithFrame:CGRectMake(0, 0, self.tableView.width, 50)];
    headerView.padding = UIEdgeInsetsMake(15, 15, 15, 15);

    UILabel *label = [UILabel createLabelText:@"检测记录" font:UIFontMake(15) textColor:COLOR1515];
    label.mySize = kAutoSize;
    [headerView addSubview:label];

    self.tableView.tableHeaderView = headerView;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ReportTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReportTableCell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    return  cell;
}

//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//
//return nil;
//
//}
//
//-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//
//return nil;
//
//}
@end
